/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Affichage;

/**
 *
 * @author Lâm
 */
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class CustomPanel extends JPanel {

    private BufferedImage img;

    public CustomPanel(String file) throws IOException {
        this.img = ImageIO.read(new File(file));
    }
    public void changeMap(String file) throws IOException{
        this.img = ImageIO.read(new File(file));
        this.getGraphics().drawImage(img, 0,0,this);
    }

    @Override
    public void paintComponent(Graphics g) {
        try {
            g.drawImage(img, 0, 0, this);
        } catch (Exception E) {

        }
    }
}
